home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_13_08 / beddow / netbios.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-02-02  |  3.8 KB  |  96 lines

  1. /* ************************************ */
  2. /* Include file for Net Bios Interface  */
  3.  
  4. typedef void (far *FARPROC)() ;
  5. typedef void (*PROC)() ;
  6.  
  7. #define NETTIMEOUTERR 0x30   // Unused error code
  8.  
  9. /* Network control block structure */
  10. struct Ncb {
  11.     unsigned char    NCB_command;    // NCB COMMAND FIELD
  12.     unsigned char    NCB_retcode;    // NCB RETURN CODE
  13.     unsigned char    NCB_lsn;    // NCB LOCAL SESSION NUMBER
  14.     unsigned char    NCB_num;    // NCB ALIAS NUMBER
  15.     void far *    NCB_buffer;     // NCB POINTER TO MESSAGE BUFFER
  16.     unsigned int    NCB_length;    // NCB LENGTH (IN unsigned charS)
  17.     unsigned char    NCB_callname[16];    // NCB NAME ON REMOTE ATTACHMENT
  18.     unsigned char    NCB_name[16];    // NCB ALIAS NAME
  19.     unsigned char    NCB_rto;    // NCB RECEIVE TIMEOUT
  20.     unsigned char    NCB_sto;    // NCB SEND TIMEOUT
  21.     FARPROC NCB_post;        // NCB POINTER TO POST ROUTINE
  22.     unsigned char    NCB_lana_num;    // NCB ATTACHMENT #1 FOR SECOND ATTACHMENT
  23.     unsigned char    NCB_cmd_cplt;    // COMMAND PENDING INDICATION
  24.     unsigned char    NCB_reserve[14];        // NCB RESERVED AREA
  25. };
  26.  
  27. /* Net name descriptor */
  28. struct netrpcserver {
  29.        char *name ;            // Server network name
  30.        int id ;                         // Server name id
  31.        int replysize ;            // Size of reply structure in bytes
  32.        unsigned int errcnt ;        // Number of network errors while in use
  33.        unsigned int last_dgstat ;    // Last error value
  34.        struct Ncb *receivencbptr ;      // Pointer to receive NCB
  35.        struct Ncb *sendncbptr ;        // Pointer to send NCB
  36.        void *dgbufin ;            // Pointer to input buffer
  37.        void *(*rpc)(void *) ;           // Pointer to remote procedure
  38.        struct netrpcserver *prev ;      // Link
  39.        } ;
  40.  
  41. #define NCBNO_WAIT    0x0080            // Flag for 'no wait' commands
  42.  
  43.     //
  44.     //    NetBIOS command code definitions.
  45.     //
  46.     //    OR these command codes with NCBNO_WAIT for command
  47.     //    with no wait.
  48.     //
  49.  
  50. #define    NCBRESET        0x0032    // Reset local attachment
  51. #define NCBSTATUS        0x0033    // Receive status of sessions
  52. #define NCBCANCEL        0x0035    // Cancel request
  53. #define NCBADDNAME        0x0030    // Add unique name
  54. #define NCBADDGROUPNAME     0x0036    // Add group name
  55. #define NCBDELETENAME        0x0031  // Delete name
  56. #define NCBCALL         0x0010  // Open session
  57. #define NCBLISTEN        0x0011  // Listen for a call
  58. #define NCBHANGUP        0x0012  // End a session
  59. #define NCBSEND         0x0014  // Send
  60. #define NCBSENDMULTIPLE     0x0017  // Send multiple
  61. #define NCBRECEIVE        0x0015  // Receive
  62. #define NCBRECEIVEANY        0x0016  // Receive from any
  63. #define NCBSESSIONSTATUS       0x0034  // Session status
  64. #define NCBSENDDATAGRAM     0x0020  // Send a datagram
  65. #define NCBRECEIVEDATAGRAM     0x0021  // Receive a datagram
  66. #define NCBSENDBROADCAST     0x0022  // Send a broadcast datagram
  67. #define NCBRECEIVEBROADCAST      0x0023     // Receive a broadcast datagram
  68. #define NCBINVALID        0x007f    // An invalid NCB command
  69.  
  70. /* Datagram max size */
  71. #define DGRAMSIZE 512
  72. /* Structure to set buffer size */
  73. struct dgbufsize {
  74.        char buf[DGRAMSIZE] ; } ;
  75.        
  76. /* Function Prototypes */
  77. net_name_command(int, char *, PROC, struct Ncb *) ;
  78. net_dgram_command(int, int, char *, void *, int, FARPROC, struct Ncb *) ;
  79. net_command_cancel(struct Ncb *, struct Ncb *) ;
  80. char *ret_ncb_callname(char *, struct Ncb *) ;
  81. struct netrpcserver *install_rpcserver(char *, void *(*)(void *), int) ;
  82. void remove_all_rpcservers(void) ;
  83. net_transact(char *, void *, int, void *, int) ;
  84. open_net_client(char *) ;
  85. close_net_client(void) ;
  86. void net_comms() ;
  87.  
  88. /* Name macros take a name and a Ncb.
  89.    Defaults to wait mode, no post function. */
  90. #define NetAddName(a,b) net_name_command(NCBADDNAME,a,NULL,&(b))
  91. #define NetDelName(a,b) net_name_command(NCBDELETENAME,a,NULL,&(b))
  92. #define NetDelName_p(a,b) net_name_command(NCBDELETENAME,a,NULL,(b))
  93.  
  94. /* Transaction macro*/
  95. #define NetTransact(b,c,d) net_transact((b),&(c),sizeof(c),&(d),sizeof(d))
  96.